/*
 ------------------------------------------------------------------------------
 Copyright (C) 2006-2007 Team Blur.

 This file is part of the Quantum Engine source code.

 The Quantum Engine source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The Quantum Engine source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the Quantum Engine source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


#ifndef __SG_ENTITY_H__
#define __SG_ENTITY_H__


typedef enum {
	EF_GODMODE						= BIT(0),
	EF_NOCLIP						= BIT(1)
} entityFlags_t;

typedef struct entity_s {
	const char *			className;
	const char *			name;
	int						flags;

	entityState_t			state;
	entityState_t			baseline;

	int						snapshotCount;

	odVec3					origin;
	odAngles				angles;
	odMat3					axis;

	struct entity_s *		owner;

	struct client_s *		client;				// NULL if not a client

	odDict					spawnDict;			// Dictionary of key/value pairs, used for entity spawning

	int						health;

	// Clipping information
	bool					linked;

	struct clipSector_s *	clipSector;
	struct entity_s *		nextInClipSector;

	clipModel_t *			clipModel;			// If NULL, use a simple bounding box

	int						contents;
	odBounds				bounds;
	odBounds				absBounds;			// Translated and rotated

	// Callback functions
	void					(*Think)(struct entity_s *self);
	void					(*Touch)(struct entity_s *self, struct entity_s *other, const trace_t trace);
	void					(*Use)(struct entity_s *self, struct entity_s *other, struct entity_s *activator);
	void					(*Damage)(struct entity_s *self, struct entity_s *attacker, int damage);
	void					(*Kill)(struct entity_s *self, struct entity_s *inflictor, struct entity_s *attacker, int damage, int meansOfDeath);
} entity_t;

entity_t *		SG_AllocEntity (void);
entity_t *		SG_AllocEntitySlot (int number);
void			SG_FreeEntity (entity_t *entity);

void			SG_WriteBaseline (entity_t *entity, ByteBuffer *msg);


#endif	// __SG_ENTITY_H__
